﻿#define _CRT_SECURE_NO_WARNINGS 1

// 1.游游的重组偶数
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int keyi;
void solve()
{
	int arr[10] = { 0 };
	int x;
	cin >> x;
	if (x % 2 == 0)
	{
		cout << x << endl;
		return;
	}
	int cnt = 0;
	int flag = 0;
	while (x)
	{
		arr[cnt++] = x % 10;
		x /= 10;
	}
	for (int i = 0; i < cnt; ++i)
	{
		if (arr[i] % 2 == 0)
		{
			keyi = i;
			flag = 1;
		}
	}
	if (flag == 0)
	{
		cout << -1 << endl;
		return;
	}
	string ret;
	for (int i = 0; i < cnt; ++i)
	{
		if (i != keyi)
		{
			ret += arr[i] + '0';
		}
	}
	ret += arr[keyi] + '0';
	cout << ret << endl;
}
int main() 
{
	int t;
	cin >> t;
	while (t--)
		solve();
	return 0;
}

// 2.体操队形
#include <iostream>
using namespace std;
const int N = 15;
int ret;
int n;
bool vis[N];
int arr[N];
void dfs(int pos)
{
	if (pos == n + 1) // 找到⼀种合法⽅案
	{
		ret++;
		return;
	}

	for (int i = 1; i <= n; i++)
	{
		if (vis[i]) continue; // 当前 i 已经放过了 - 剪枝
		if (vis[arr[i]]) return; // 剪枝
		vis[i] = true; // 相当于放上 i 号队员
		dfs(pos + 1);
		vis[i] = false; // 回溯- 还原现场
	}
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> arr[i];

	dfs(1);

	cout << ret << endl;

	return 0;
}



// 3.二叉树中的最大路径和
// 方法一
#include <queue>
const int N = 1e5 + 10;
queue<TreeNode*> q;
int arr[N];
class Solution {
public:
	/**
	 * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
	 *
	 *
	 * @param root TreeNode类
	 * @return int整型
	 */
	int maxPathSum(TreeNode* root) {
		if (!root->left && !root->right)
			return root->val;

		// BFS宽度优先遍历
		int sum = 0;
		int k = 0;
		int flag = 1;
		q.push(root);
		while (q.size())
		{
			TreeNode* tmp = q.front();
			q.pop();
			if (tmp->left)
				q.push(tmp->left);
			if (tmp->right)
				q.push(tmp->right);

			if (flag == 0)
			{
				arr[k++] = sum + tmp->val;
				sum = max(sum, tmp->val);
				flag = 1;
			}
			else
			{
				sum += tmp->val;
			}

			arr[k++] = max(sum, tmp->val);
			if (arr[k - 1] == tmp->val)
			{
				sum = arr[k - 1];
			}
			if (!tmp->left && !tmp->right)
			{
				flag = 0;
			}
		}
		int m = -1000 * 1e5 - 1;
		for (int i = 0; i < k; ++i)
			if (arr[i] > m)
				m = arr[i];
		// for(int i = 0; i < k; ++i)
		//     cout << arr[i] << ' ';
		return m;
	}
};

// 方法二
class Solution
{
public:
	int ret = -1010;
	int maxPathSum(TreeNode* root)
	{
		dfs(root);
		return ret;
	}
	int dfs(TreeNode* root)
	{
		if (root == nullptr) return 0;
		int l = max(0, dfs(root->left));// 左⼦树的最⼤单链和
		int r = max(0, dfs(root->right)); // 右⼦树的最⼤单链和
		// 经过root的最⼤路径和
		ret = max(ret, root->val + l + r);
		return root->val + max(l, r);
	}
};